import {service as request} from '@/utils/request'

// 条件分页查询
export function getList(data) {
  return request({
    url: `/hawk/hosts/search/${data.page.current}/${data.page.size}`,
    method: 'get',
    params:data.query
  })
}


/**
 * 判断 主机 host 是否存在
 * @param {*} host 
 * @returns 
 */
export function isHostExists(query) {
  return request({
    url: `/hawk/hosts/exists`,
    method: 'get',
    params:query
  })
}


/**
 * 查询该主机是否有所属业务系统
 * 查询主机是否属于业务系统，是返回true,不是返回false,返回true让其从业务系统配置告警
 * @param {*} hostId 
 * @returns 
 */
export function queryHostBus(hostId) {
  return request({
    url: `/hawk/hosts/hasbussiness/${hostId}`,
    method: 'get'
  })
}


// 获得主机的模板
// 13.1 
export function getHostInterface(hostId) {
  return request({
    url: `/hawk/interface/get/${hostId}`,
    method: 'get'
  })
}

// 为主机添加告警
// 12.11 
export function deleteAlarm(hostId) {
  return request({
    url: `/hawk/hosts/remove/alarm/${hostId}`,
    method: 'delete',
  })
}


// 为主机添加告警
// 12.1 
export function addAlarm(data) {
  return request({
    url: `/hawk/hosts/assign/alarm`,
    method: 'post',
    data
  })
}



/**
 * // 获得主机的告警信息
// 12.4
 * @param {*} hostId 
 * @returns 
 */
export function getHostAlarm(hostId) {
  return request({
    url: `/hawk/hosts/get/alarm/${hostId}`,
    method: 'get'
  })
}

export function searchList(data) {
  return request({
    url: `/monitor/config/item/${JSON.stringify(data)}`,
    method: 'get'
  })
}
//主机添加
// 12.12
export function doAdd(data) {
  return request({
    url: '/hawk/hosts/save',
    method: 'post',
    data
  })
}
//主机修改
// 更新主机  12.15
export function doEdit(data) {
  return request({
    url: '/hawk/hosts/update',
    method: 'put',
    data
  })
}
// 删除
// 12.2
export function doDelete(ids) {
  return request({
    url: `/hawk/hosts/del`,
    method: 'delete',
    data:ids
  })
}

/**
 * 获得主机详细信息
 * @param {*} hostId 
 * @returns 
 */
export function getHostDetail(hostId) {
  return request({
    url: `/hawk/hosts/get/${hostId}`,
    method: 'get'
  })
}



export function getOne(id) {
  return request({
    url: `/monitor/config/item/${id}`,
    method: 'get'
  })
}
export function getAll() {
  return request({
    url: `/monitor/config/item`,
    method: 'get'
  })
}
export function separateItem(data){
  return request({
    url: '/monitor/config/item/separate',
    method: 'put',
    data
  })
}